/*
 * @Author: LVGRAPE
 * @Date: 2023-09-07 17:59:27
 * @LastEditTime: 2025-04-23 14:03:40
 * @LastEditors: LVGRAPE
 * @Description:
 * @FilePath: \ZINO_FC_V4\ZINO\hardware\spi_bus\spi_bus.c
 * 要啥没啥，爱咋咋的
 */
#include <rtdevice.h>
#include "drv_spi.h"
#include "zino.h"
#define DBG_TAG "spi_bus"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

int zino_spi_bus_init(void)
{
    LOG_I("adding spi bus:");
    if (rt_hw_spi_device_attach("spi1", "spi_nrf", GPIOC, GPIO_PINS_10) != RT_EOK)
    {
        LOG_E("spi1 si24r1 attach failed!");

    }
    else
    {
        LOG_I("attach spi1 si24r1 !");
    }
    if (rt_hw_spi_device_attach("spi1", "spi_spl", GPIOA, GPIO_PINS_14) != RT_EOK)
    {
        LOG_E("spi1 spl06 attach failed!");
    }
    else {
        LOG_I("attach spi1 spl06 !");
    }
    if (rt_hw_spi_device_attach("spi1", "spi_icm", GPIOA, GPIO_PINS_13) != RT_EOK)
    {
        LOG_E("attach spi1 icm42688p attach failed!");
    }
    else {
        LOG_I("attach spi1 icm42688p !");
    }
    if (rt_hw_spi_device_attach("spi1", "spi_pmw", GPIOB, GPIO_PINS_7) != RT_EOK)
    {
        LOG_E("attach spi1 pmw3901 attach failed!");
    }
    else {
        LOG_I("attach spi1 pmw3901 !");
    }
    LOG_I("spi bus add success!");
    return RT_EOK;
}

ZINO_PREV_EXPORT(zino_spi_bus_init);
